#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <utility>
#include <tuple>
using namespace std;

int getRandNum(int maxNum)
{
    return rand()%maxNum;
}

class cat
{
private:
    string eyeColor;
    string furColor;
    string furLength;

public:
    static const string allFurColor[3];
    static const string allEyeColor[3];
    static const string allLength[2];

    cat() :
    eyeColor(allFurColor[getRandNum(3)]), furColor(allEyeColor[getRandNum(3)]), furLength(allLength[getRandNum(2)]) {}

    string getEyeColor() const { return this->eyeColor; }
    string getFurColor() const { return this->furColor; }
    string getFurLength() const { return this->furLength; }
    void setEyeColor(string eyeColor) { this->eyeColor=eyeColor; }
    void setFurColor(string furColor) { this->furColor=furColor; }
    void setFurLength(string furLength) { this->furLength=furLength; }
    string output()
    {
        return "Cat - eyeColor:"+this->eyeColor+" furColor:"+this->furColor+" furLength:"+this->furLength;
    }
};
const string cat::allFurColor[3] = {"green","blue","brown"};
const string cat::allEyeColor[3] = {"black","gray","brown"};
const string cat::allLength[2] = {"Long","Short"};

typedef pair<cat*,cat*> fightPair;

class cage
{
private:
    vector<cat*> allCat;
    int furColorNum[3] = {0,0,0};

    void outputAllFight(vector<fightPair>&allFightPair) const
    {
        if(allFightPair.empty())
            cout<<"There is no fight in the cage"<<endl;
        else
        {
            for(fightPair i : allFightPair)
            {
                cat* c1;
                cat* c2;
                tie(c1,c2)=i;
                cout<<"["<<c1->output()<<"] fight with ["<<c2->output()<<"]"<<endl;
            }
        }
    }

    void addAllFurColor(string color1, string color2, vector<fightPair>&allFightPair) const
    {
        for(cat* ci : this->allCat)
        {
            if(ci->getFurColor()==color1)
            {
                for(cat* cj : this->allCat)
                {
                    if(cj->getFurColor()==color2)
                        allFightPair.push_back(fightPair(ci,cj));
                }
            }
        }
    }

    void fightTesting2(vector<fightPair>&allFightPair) const
    {
        for(unsigned int i=0;i<this->allCat.size();i++)
        {
            for(unsigned int j=0;j<this->allCat.size();j++)
            {
                if(i!=j && i<j)
                {
                    cat* c1=this->allCat[i];
                    cat* c2=this->allCat[j];
                    if(c1->getFurColor()==c2->getFurColor() && c1->getEyeColor()!=c2->getEyeColor())
                        allFightPair.push_back(fightPair(c1,c2));
                }
            }
        }
    }

    void fightTesting1(vector<fightPair>&allFightPair) const
    {
        for(unsigned int i=0;i<3;i++)
        {
            for(unsigned int j=0;j<3;j++)
            {
                if(this->furColorNum[i] > this->furColorNum[j])
                    this->addAllFurColor(cat::allEyeColor[i],cat::allEyeColor[j],allFightPair);
            }
        }
    }

public:
    void addCat(cat *c)
    {
        for(unsigned int i=0;i<3;i++)
        {
            if(c->getFurColor()==cat::allEyeColor[i])
                this->furColorNum[i]++;
        }
        allCat.push_back(c);
        //添加完毕，处理fight
        vector<fightPair> allFightPair;
        this->fightTesting1(allFightPair);
        this->fightTesting2(allFightPair);
        outputAllFight(allFightPair);
    }

    ~cage()
    {
        for(cat* c : this->allCat)
            delete c;
    }
};


int main()
{
    srand(time(0));
    cage acage;
    while(1)
    {
        cin.get();
        cat *newCat = new cat;
        cout<<"new "<<newCat->output()<<endl;
        acage.addCat(newCat);
    }
}
